package dr.joketalker.controller.view;

import java.util.LinkedList;
import java.util.List;


import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import dr.joketalker.R;
import dr.joketalker.entity.Joke;

public class ListRowAdapterSearch extends BaseAdapter{

	
	Activity context;
	protected List<View> listItem = new LinkedList<View>();;
	protected List<Integer> listItemSeperatorPosition;
	
	public ListRowAdapterSearch(Activity context){
		this.context = context;
	    this.listItemSeperatorPosition = new LinkedList<Integer>();
	}
	
	  public void addItem(JokeView listRow)
      {
          listItem.add(listRow);     
      }
	  
	  public void addItem(Joke joke){
		  addItem(new JokeView(context,joke));
	  }
	  

      public void addItemSeperator(MyView listRow)
      {
          listItemSeperatorPosition.add(listItem.size());
          listItem.add(listRow);
      }

      public boolean isItemSeperator(int position)
      {
          return listItemSeperatorPosition.contains(position);
      }


     @Override
	public  int getItemViewType(int position){
    	 return super.getItemViewType(position);
     }




 	@Override
 	public View getView(int position, View convertView, ViewGroup parent) 
    {
		return listItem.get(position);
	}

	public void setList(List<Joke> list) {
		listItem.clear();
		for(Joke joke : list ){
			addItem(joke);
		}
		
	}

	@Override
	public int getCount() {
		return listItem.size();
	}

	@Override
	public Object getItem(int position) {
		return listItem.get(position);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	public void addEndItem(OneLineView oneLineView) {
		// TODO Auto-generated method stub
		listItem.add(oneLineView);
	}



}
